﻿// ***********************************************************************
// Assembly         : INNOVACALL.Framework.Common
// Author           : LJO+01 (Laurent Jordi)
// Created          : 06-05-2013
// Last Modified By : LJO+01 (Laurent Jordi)
// Last Modified On : 06-05-2013
// ***********************************************************************
// <copyright file="DisplayNameLocalizedAttribute.cs" company="Copyright © Innovacall 2011">
//     Copyright (c) Copyright © Innovacall 2011. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.ComponentModel;

namespace INNOVACALL.Framework.Common.MVCHelpers.Localization
{
    /// <summary>
    /// Class DisplayNameLocalizedAttribute
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event)]
    public class DisplayNameLocalizedAttribute : DisplayNameAttribute
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DisplayNameLocalizedAttribute"/> class.
        /// </summary>
        /// <param name="resourceManagerProvider">The resource manager provider.</param>
        /// <param name="resourceKey">The resource key.</param>
        public DisplayNameLocalizedAttribute(Type resourceManagerProvider, string resourceKey)
            : base(CommonLocalization.LookupResource(resourceManagerProvider, resourceKey))
        {
        }
    }
    /// <summary>
    /// Recherche un membre dans la ressource pour les vues
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event)]
    public class DisplayNameLocalizedEntityAttributex : DisplayNameAttribute
    {
        /// <summary>
        /// Find a ressource build like this View_{viewName}_{entityName}_{resourceKey}
        /// </summary>
        /// <param name="resourceManagerProvider">The resource manager provider.</param>
        /// <param name="viewName">Name of the view.</param>
        /// <param name="entityName">Name of the entity.</param>
        /// <param name="resourceKey">The resource key.</param>
        public DisplayNameLocalizedEntityAttributex(Type resourceManagerProvider, string viewName, string entityName, string resourceKey)
            : base(CommonLocalization.LookupResource(resourceManagerProvider, string.Format(@"View_{0}_{1}_{2}", viewName, entityName, resourceKey)))
        {
            var a = string.Format(@"{0}_{1}_{2}", viewName, entityName, resourceKey);
            a = CommonLocalization.LookupResource(resourceManagerProvider, a);
        }

        /// <summary>
        /// Find a ressource build like this Ety_{entityName}_{resourceKey}
        /// </summary>
        /// <param name="resourceManagerProvider">The resource manager provider.</param>
        /// <param name="entityName">Name of the entity.</param>
        /// <param name="resourceKey">The resource key.</param>
        public DisplayNameLocalizedEntityAttributex(Type resourceManagerProvider, string entityName, string resourceKey)
            : base(CommonLocalization.LookupResource(resourceManagerProvider, string.Format(@"Ety_{0}_{1}", entityName, resourceKey)))
        {
            var a = string.Format(@"{0}_{1}", entityName, resourceKey);
            a = CommonLocalization.LookupResource(resourceManagerProvider, a);
        }

    }
}
